<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Api_Model_Photo
{
	private $photo_id;
	private $location_id;
	private $user_id;
	private $photo_link;
	private $caption;
	private $created_time;
	private $location_share_time;
	private $tour_share_time;

	public function __construct($photo_row = null) {
		if(!is_null($photo_row) && $photo_row instanceof Zend_Db_Table_Row) {
			$this->photo_id = $photo_row->photo_id;
			$this->location_id = $photo_row->location_id;
			$this->user_id = $photo_row->user_id;
			$this->photo_link = $photo_row->photo_link;
			$this->caption = $photo_row->caption;
			$this->created_time = $photo_row->created_time;
			$this->location_share_time = $photo_row->location_share_time;
			$this->tour_share_time = $photo_row->tour_share_time;
		}
	}

	public function __set($name, $value) {
		switch($name) {
			case 'photo_id':
				if(!is_null($this->photo_id)) {
					throw new Exception('Cannot update travel photo\'s id');
				}
				break;
			case 'location_id':
				if(!is_null($this->location_id)) {
					throw new Exception('Cannot update location\'s id');
				}
				break;
			case 'user_id':
				if(!is_null($this->user_id)) {
					throw new Exception('Cannot update user\'s id');
				}
				break;
			case 'photo_link':
				if(!is_null($this->photo_link)) {
					throw new Exception('Cannot update photo link');
				}
				break;
			case 'caption':
				if(!is_null($this->caption)) {
					throw new Exception('Cannot update caption');
				}
				break;
			case 'created_time':
				if(!is_null($this->created_time)) {
					throw new Exception('Cannot update created_time');
				}
				break;
			case 'created_time':
				if(!is_null($this->location_share_time)) {
					throw new Exception('Cannot update created_time');
				}
				break;
			case 'created_time':
				if(!is_null($this->tour_share_time)) {
					throw new Exception('Cannot update created_time');
				}
				break;
		}
		$this->$name = $value;
	}

	public function __get($name) {
		return $this->$name;
	}
}


